//
//  UIColor+hex.swift
//  GRVoice
//
//  Created by tucici on 2021/10/12.
//  Copyright © 2021 国瑞语音. All rights reserved.
//

import Foundation
import UIKit
#if canImport(TCC_String)
import TCC_String
#endif
#if canImport(TCC_Extension)
import TCC_Extension
#endif
public func Hex(_ s:String, _ a:Float)->UIColor{
    return UIColor.colorHex(s, a)
}
public func Hex(_ s:String)->UIColor{
    return UIColor.colorHex(s, 1)
}
//MARK: - 十六进制字符串转换成颜色
@objc public extension UIColor
{
    
    /// 将十六进制转换成UIColor
    /// - Parameter hex: 十六进制字符串
    /// - Returns: UIColor
    class func colorHex(_ hex : String) -> UIColor
    {
        return hex.color()
    }
    
    /// 将十六进制转换成UIColor
    /// - Parameters:
    ///   - hex: 十六进制字符串
    ///   - alpha: 透明值
    /// - Returns: UIColor
    class func colorHex(_ hex : String, _ alpha : Float) -> UIColor
    {
        return hex.color(alpha)
    }
    
    class  func RGBA(_ R:Int, _ G : Int, _ B : Int, _ A : Int) -> UIColor
    {
        return UIColor.init(red:CGFloat(R) / 255.0, green:CGFloat(G) / 255.5, blue:CGFloat(B) / 255.0, alpha: CGFloat(A))
    }
    
    
}
